﻿
@{
    Layout = null;
}

@*<div>经销商管理</div>*@
<style>
    #daoru input[type="file"] {
        opacity: 0;
    }
</style>
<script src="~/Scripts/Bootstrap/js/bootstrap-select.js" charset="utf-8" type="text/javascript"></script>
<link href="~/Scripts/Bootstrap/css/bootstrap-select.min.css" rel="stylesheet" />
<script src="~/Scripts/MGJJS/Manager/Dealer.js"></script>

<div class="mtlr15">
    <div class="row">
        <div class="col-lg-4 col-md-4 col-sm-4" style="padding:0">
            <button type="button" class="btn btn-success" onclick="$.MGJ.Dealer.Dialog_AEdit()">
                <i class="glyphicon glyphicon-plus-sign"></i>
                新建
            </button>
            <button type="button" class="btn btn-success" onclick="$.MGJ.Dealer.ExportDealer('#tableList')">
                <i class="glyphicon glyphicon-arrow-down"></i>
                导出excel
            </button>
            <label id="daoru" class="btn btn-success" >
                <i class="glyphicon glyphicon-arrow-down"></i>
                导入excel   
            </label>
            <button type="button" class="btn btn-success" onclick="$.MGJ.Dealer.ImportDemo()">
                <i class="glyphicon glyphicon-arrow-down"></i>
               下载excel模板
            </button>
        </div>
        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2"></div>
        <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
            <div class="input-group">
                <div class="input-group-btn" style="margin-left:1px;" onclick="detailSearch(this)">
                    <button type="button" class="btn btn-default" style="background-color: #f3f7f9; color: #76838f; ">
                        公司名称
                    </button>
                </div>
                <select id="EnterpriseBox" onchange="$.MGJ.Dealer.Ajax_PageList(1,  $(this).val());" class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="Search" data-actions-box="true" title="--机构名称--" onchange=""></select>
            </div>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-4">
            <div class="input-group">
                <input type="text" id="Key" class="form-control" placeholder="经销商名称" onkeydown="if (event.keyCode == 13) { $.MGJ.Dealer.Ajax_PageList(1, $('#enterprisebox').val()); }">
                <span class="input-group-addon" onclick="$.MGJ.Dealer.Ajax_PageList(1, $('#enterprisebox').val());">
                    <span class="glyphicon glyphicon-search"></span>
                </span>
            </div>
        </div>
    </div>
    <div id="wh100">
        <div class="fixed-table">
            <div id="over">
                <div class="fixed-table-left">
                    <table>
                        <thead>
                            <tr>
                                <th><input type="checkbox" class="AllClickCheckbox"></th>
                                <th>编号</th>
                                <th>所属机构</th>
                            </tr>
                        </thead>
                        <tbody id="tableList_left" style="display:none;" binding="{'pageId':'ShoppingPager','pageCallback':'$.MGJ.Dealer.Ajax_PageList'}">
                            <tr>
                                <td width="15"><input type="checkbox" class="AllClickChild" binding="{'ID':'ID'}"></td>
                                <td binding="{'text':'ID','title':'ID'}"> </td>
                                <td binding="{'text':'EnterpriseName','title':'EnterpriseName'}"> </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="fixed-table-middle" style="width:100%;">
                    <table style="width:100%;">
                        <thead>
                            <tr>
                                <th class="empty"><input type="checkbox" class="AllClickCheckbox"></th>
                                <th>编号</th>
                                <th>所属机构</th>
                                <th>经销商名称</th>
                                <th>联系人</th>
                                <th>联系电话</th>
                                <th>经销商等级</th>
                                <th>所属片区</th>
                                <th>操作人</th>
                                <th>管辖省</th>
                                <th>管辖市</th>
                                <th>管辖区(县)</th> 
                                <th>所跨省</th>
                                <th>所跨市</th>
                                <th>所跨区(县)</th>
                                @*<th>邮箱</th>
                                <th>所在地</th>
                                <th>详细地址</th>
                                <th>备注</th>*@
                                <th class="empty">操作</th>
                            </tr>
                        </thead>
                        <tbody id="tableList" style="display:none;" binding="{'pageId':'ShoppingPager','pageCallback':'$.MGJ.Dealer.Ajax_PageList','emptyHtml':OMID_EmptyHtml}">
                            <tr>
                                <td><input type="checkbox"></td>
                                <td binding="{'text':'ID','title':'ID'}"> </td>
                                <td binding="{'text':'EnterpriseName','title':'EnterpriseName'}"> </td>
                                <td binding="{'text':'Name','title':'Name'}"></td>
                                <td binding="{'text':'Contacts'}"></td>
                                <td binding="{'text':'ContactMobile'}"></td>
                                <td binding="{'text':'DisLevelName'}"></td>
                                <td binding="{'text':'SalesArea','title':'SalesArea'}"></td>
                                <td binding="{'text':'CreateLoginName'}"></td>
                                <td style="max-width:400px;" binding="{'text':'JurisdictionPrivanceName','title':'JurisdictionPrivanceName'}"></td>
                                <td style="max-width:400px;" binding="{'text':'JurisdictionCityName','title':'JurisdictionCityName'}"></td>
                                <td style="max-width:400px;" binding="{'text':'JurisdictionRegionName','title':'JurisdictionRegionName'}"></td>
                                <td binding="{'text':'AcrossPrivanceName'}"></td>
                                <td binding="{'text':'AcrossCityName'}"></td>
                                <td binding="{'text':'AcrossRegionName'}"></td>
                                <td>
                                    <a>编辑</a>
                                    <a>删除</a>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="fixed-table-right">
                    <table>
                        <thead>
                            <tr>
                                <th style="padding:6px 15px 7px;">操作</th>
                            </tr>
                        </thead>
                        <tbody id="tableList_right" style="display:none;" binding="{'pageId':'ShoppingPager','pageCallback':'$.MGJ.Dealer.Ajax_PageList'}">
                            <tr>
                                <td style="padding:6px 15px 7px;">
                                    <a binding="{'ID':'ID'}" onclick="$.MGJ.Dealer.Dialog_AEdit(this)">编辑</a>
                                    <a binding="{'ID':'ID'}" onclick="$.MGJ.Dealer.Ajax_Del(this)">删除</a>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="ShoppingPager"></div>
        </div>
    </div>
</div>

<script>
    var ColspanNub = $(".fixed-table-middle").find("tr").children("td").length
    window.OMID_EmptyHtml = '<tr><td colspan="' + ColspanNub + '"><p class="no-result">无符合条件的数据结果</p></td></tr>';
    $(function () {
        $.MGJ.Dealer.Ajax_PageList(1,0);
    });

    function EnterpriseBox() {
        $.ajax({
            type: "Get",
            url: "/CodeManage/SelEnterpriseBox",
            dataType: "json",
            success: function (data) {
                var $EnterpriseBox = "<option id='0' value='0'>--全部--</option>";
                for (var i = 0; i < data.length ; i++) {
                    $EnterpriseBox += " <option id='" + data[i].ID + "' value='" + data[i].ID + "'>" + data[i].EnterpriseName + "</option>";
                }
                $("#EnterpriseBox").append($EnterpriseBox);
                $('#EnterpriseBox').selectpicker();
            }
        })
    }

    EnterpriseBox();


    var GUID = WebUploader.Base.guid();
    var uploader = WebUploader.create({
        // swf文件路径
        swf: '~/Scripts/WebUploader/Uploader.swf',
        // 文件接收服务端。
        server: 'DBH/ProcessRequest_Excel',
        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: {
            id: '#daoru',
            multiple: false
        },
        accept: {
            title: '文本',
            extensions: 'xlsx',
            mimeTypes: '*.xlsx'
        },
        chunked: true,//分片处理大文件
        chunkSize: 2 * 1024 * 1024,
        //由于Http的无状态特征，在往服务器发送数据过程传递一个进入当前页面是生成的GUID作为标示
        formData: { guid: GUID },
        fileNumLimit: 2,  //上传文件的数量限制
        compress: false, //图片在上传前不进行压缩
        fileSizeLimit: 6 * 1024 * 1024 * 1024,    // 所有文件总大小限制 6G
        fileSingleSizeLimit: 5 * 1024 * 1024 * 1024,   // 单个文件大小限制 5 G
        threads: 1, //上传并发数
        disableGlobalDnd: true,
    });
    // 当有文件被添加进队列的时候
    uploader.on('fileQueued', function (file) {
        uploader.upload();

    });
    // 文件上传过程中创建进度条实时显示。
    uploader.on('uploadProgress', function (file, percentage) {
        
    });
    uploader.on('uploadSuccess', function (file, response) {

        $.post("Manager/Import", { filePath: response._raw },
            function (res) {
                $.L.msgSuccess(res);
            });
    });

    uploader.on('uploadError', function (file) {

        $.L.msgWarning("上传出错！");
         
    });


    uploader.on('error', function () {
        $.L.msgError("格式有误,请上传excel文件！");
    })

    uploader.on('uploadComplete', function (file) {
           
    });
</script>